home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / File Dropper 2.0ß1 / FD Starter / Starter Main.c < prev   
C/C++ Source or Header  |  1994-01-04  |  5KB  |  138 lines

  1. #include "FD Interface.h"
  2.  
  3. /*****
  4.  * This is the module's main entrypoint.
  5.  *****/
  6. Boolean ModuleMain( short message, ModuleDataRec *moduleData)
  7. {
  8.     Boolean    returnValue = TRUE;
  9.     
  10.     switch (message)
  11.     {
  12.         case eStartup    :
  13.                                     // The application just started.  Set up any custom 
  14.                                     // stuff you want.
  15.             SetStatusParams( TRUE, TRUE, "\pMoof!");
  16.             returnValue = TRUE;        // TRUE means everything is OK.  If you return FALSE here, 
  17.                                     // you will receive an eQuitting message and File Dropper 
  18.                                     // will quit.  You will NOT get an eDispose message.
  19.             break;
  20.             
  21.         case eSFInitialize    :
  22.             /*
  23.              * The SFGetFile is about to be brought up - you can install your own at this point
  24.              * if you want to.
  25.              * If the user chooses a file, you will receive one each of eValidate and eProcessFile
  26.              * messages.  If s/he chooses a folder, you will receive an eValidate and eProcessFile
  27.              * message for each file in the folder, and each file in each folder on down the line.
  28.              * NOTE: you only get one of these for each time the SFGetFile dialog comes up.  If 
  29.              * you want to initialize something before each file, do it in the eProcessFile case.
  30.              */
  31.             
  32.             returnValue = TRUE;        // TRUE means everything is OK.  If you return FALSE here, 
  33.                                     // you will receive an eQuitting message and File Dropper 
  34.                                     // will quit.  You will NOT get an eDispose message.
  35.             break;
  36.                 
  37.         case eAEInitialize    :
  38.             // An 'odoc' AppleEvent has been received - you are about to be flooded with 
  39.             // eValidateFile and eProcessFile messages (a set for each file you need to process)
  40.             // NOTE, you only get one eAEInitialize for the whole batch of files.  If you want to
  41.             // initialize something before each file, do it in the eProcessFile case.
  42.             
  43.             returnValue = TRUE;        // TRUE means everything is OK.  If you return FALSE here, 
  44.                                     // you will receive an eQuitting message and File Dropper 
  45.                                     // will quit.  You will NOT get an eDispose message.
  46.             break;
  47.              
  48.         case eValidateFile    :
  49.             SetStatusParams( TRUE, TRUE, NULL);
  50.                                     // validate the file here
  51.             returnValue = TRUE;        // TRUE means theFile in moduleData is one that
  52.                                     // you want to process
  53.             break;
  54.             
  55.         case eProcessFile    :
  56.                                     // Do your stuff -    theFile in moduleData is the file 
  57.                                     //                    you need to process
  58.                                     // Here, I simply am showing off the progress bar stuff.
  59.             {
  60.                 short    i;
  61.                 
  62.                 ChangeStatusMessage( moduleData->theFile->name);
  63.                 for ( i=0; i <= 50; i++) SetStatusPercentage( i);    
  64.                 
  65.                 ChangeStatusMessage( "\pProcessing phase 2");
  66.                 for ( ; i >= 25; i--) SetStatusPercentage( i);    
  67.                 
  68.                 ChangeStatusMessage( "\pFinishing up");
  69.                 for ( ; i <= 100; i++) SetStatusPercentage( i);    
  70.             }
  71.             
  72.             returnValue = TRUE;        // return TRUE to continue processing any remaining files,
  73.                                     // or FALSE to stop prematurely
  74.             break;
  75.         
  76.         case eUserCancelled    :
  77.                                     // The user clicked Cancel in the satatus dialog.  Since File
  78.                                     // Dropper handles the status dialog whenever you call 
  79.                                     // SetStatusPercentage, you will get this message only during
  80.                                     // a call to SetStatusPercentage.
  81.                                     // moduleData->theFile is the file that was being processed
  82.                                     // when the user clicked Cancel.
  83.  
  84.             returnValue = TRUE;        // Return TRUE to receive an eDispose, an eQuitting message, and
  85.                                     // have File Dropper ExitToShell.
  86.                                     // Return FALSE to pretend the Cancel didn't get clicked, although
  87.                                     // you could keep track and immediately return FALSE from the 
  88.                                     // eProcessFile case.
  89.             break;
  90.             
  91.         case eDispose        :
  92.                                     // If you allocated any storage in eSFInitialize or 
  93.                                     // eAEInitialize, dispose of it here.
  94.  
  95.             returnValue = FALSE;    // return FALSE if you want File Dropper to send you an 
  96.                                     // eQuitting message and quit.
  97.                                     // TRUE means you want to keep running
  98.             break;
  99.         
  100.         case eDoAboutBox    :
  101.                                     // Give yourself some credit.
  102.             
  103.                                     //    If you return TRUE from this message, I will handle the 
  104.                                     //    about box by reading from the STR# number 129.  I will
  105.                                     //    read all strings starting with number 1 in that resource 
  106.                                     //    and display them in the about box.  Only up to about 6 
  107.                                     //    strings will actually fit in the about box. 
  108.                                         
  109.                                     //    If you return FALSE from the eDoAboutBox message, I will 
  110.                                     //    assume that you handled the about box and do nothing.
  111.             break;
  112.         
  113.         case eQuitting        :
  114.                                     // The application is about to quit, save anything 
  115.                                     // that needs to be saved.
  116.             
  117.                                     // returnValue is ignored for this message
  118.             break;
  119.         
  120.         case eIdle            :
  121.                                     // You can do whatever you want, including nothing, here.
  122.                                     // It's continuously called when there are no files to process
  123.                                     // and File Dropper is receiving NULL events.
  124.                                     
  125.                                     // returnValue is ignored for this message
  126.             break;
  127.     }
  128.     
  129.     return returnValue;
  130. }
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.